#define GPSBABEL_INIFILE "gpsbabel.ini"
+/* Remember the filename we used so we can include it in errors. */
+char *gbinipathname;
+
static char *
find_gpsbabel_inifile(const char *path) /* can be empty or NULL */
{
}
if (name != NULL) {
res = gbfopen(name, "r", "GPSBabel");
- xfree(name);
+ if (gbinipathname) {
+ xfree(gbinipathname);
+ }
+ gbinipathname = name;
}
return res;
}
cin = lrtrim(cin);
}
if ((*cin == '\0') || (cend == NULL))
- fatal("%s: invalid section header!\n", myname);
+ fatal("%s: invalid section header '%s' in '%s'.\n", myname, cin, gbinipathname);
sec = xcalloc(1, sizeof(*sec));
inifile_entry_t *entry;
if (sec == NULL)
- fatal("%s: missing section header!\n", myname);
+ fatal("%s: missing section header in '%s'.\n", myname,gbinipathname);
entry = xcalloc(1, sizeof(*entry));
ENQUEUE_TAIL(&sec->entries, &entry->Q);
}
xfree(inifile);
}
+ if (gbinipathname) {
+ xfree(gbinipathname);
+ gbinipathname = NULL;
+ }
}
int